package cn.com.nes.site.controller.distribution;


import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.entity.vo.distribution.*;
import cn.com.nes.site.service.distribution.DistributionManagementService;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 渠道管理接口
 */
@Controller
@RequestMapping("/v2/distribution/management")
public class DistributionManagementController {

    @Resource
    private DistributionManagementService distributionManagementService;

    /**
     * 删除供给关系
     * @param vo
     * @return
     */
    @RequestMapping(value = "deleteDistributionRelationship", method = RequestMethod.POST)
    @ResponseBody
    public PageData deleteDistributionRelationship(@RequestBody @Validated DeleteDistributionRelationshipVo vo) throws Exception {
        return distributionManagementService.deleteDistributionRelationship(vo);
    }

    /**
     * 获取我的代理商、厂商、子公司
     * @param vo
     * @return
     */
    @RequestMapping(value = "getMyAgentManufactureChildCompany", method = RequestMethod.GET)
    @ResponseBody
    public PageData getMyAgentManufactureChildCompany(
            @Validated GetMyAgentManufactureChildCompanyVo vo) throws Exception {
        return distributionManagementService.getMyAgentManufactureChildCompany(vo);
    }

    /**
     * 申请新增公司
     * @param vo
     * @return
     */
    @RequestMapping(value = "addCompanyApply", method = RequestMethod.POST)
    @ResponseBody
    public PageData addCompanyApply(@RequestBody @Validated AddCompanyApplyVo vo) throws Exception {
        return distributionManagementService.addCompanyApply(vo);
    }

    /**
     * 查询申请公司列表
     * @param vo
     * @return
     */
    @RequestMapping(value = "getCompanyApplyPage", method = RequestMethod.GET)
    @ResponseBody
    public PageData getCompanyApplyPage(GetCompanyApplyVo vo) throws Exception {
        return distributionManagementService.getCompanyApplyPage(vo);
    }

    /**
     * 审核 申请的公司
     * @param vo
     * @return
     */
    @RequestMapping(value = "auditCompanyApply", method = RequestMethod.POST)
    @ResponseBody
    public PageData auditCompanyApply(@RequestBody @Validated AuditCompanyApplyVo vo) throws Exception {
        return distributionManagementService.auditCompanyApply(vo);
    }

}
